package org.s3.project.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.s3.project.common.R;
import org.s3.project.entity.Cart;
import org.s3.project.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fy
 * @version 1.0
 * @Description
 * @date 2025/2/20 10:49
 */
@CrossOrigin(origins = "*")
@RestController
public class CartMapperController {
    @Autowired
    private CartService cartService;
////    显示购物车
//    @GetMapping("selectCartByUserId")
//    public R  selectCartByUserId(Integer userId){
//        List<Cart> carts = cartService.selectCartByUserId(userId);
//        return new R().add("carts",carts);
//    }
    /*显示购车
加 模糊*/
    @GetMapping("selectCartByUserId")
    public R selectCartByUserId(Integer userId,
                  @RequestParam(required = false)String name) {
        List<Cart> list = cartService.selectCartByUserId(name,userId);
        return new R() .add("pageInfoCart", list);

    }

}
